﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;

[RequireComponent(typeof(GestureRaise))]
public class GestureRaiseDebugger : MonoBehaviour, IGestureRaiseHandler {

    GestureRaise gesture;

    public Text velocityText;
    //Text valueText;
    public Slider valueSlider;
    public Transform TestObject;
    GameObject box;

    private static readonly float MinScale = 100f;
    private static readonly float MaxScale = 200f;
    // Use this for initialization
    void Start () {
        gesture = GetComponent<GestureRaise>();
        gesture.Handler = this;
        box = GameObject.CreatePrimitive(PrimitiveType.Cube);
        box.transform.SetParent(TestObject);
        box.transform.localPosition = Vector3.zero;
        box.transform.localScale =Vector3.one * MinScale;
	}
	

    public void OnDetectStart()
    {
        valueSlider.value = 0;
    }

    public void OnDetectProgress(float progress)
    {
        valueSlider.value = progress;
        Debug.LogWarningFormat("Velocity: {0}",gesture.fVelocity);
        box.transform.localScale = Mathf.Lerp(MinScale, MaxScale, gesture.fValue) * Vector3.one;
    }

    public void OnDetectFinish()
    {
        valueSlider.value = 1;
        Debug.Log("finish raise");
    }

    public void OnDetecCancel()
    {
        valueSlider.value = 0f;
    }
}
